# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=palp
epoch=1
pkgver=2.20
pkgrel=1
pkgdesc="A Package for analyzing Lattice Polytopes"
arch=(loong64 x86_64)
url="http://hep.itp.tuwien.ac.at/~kreuzer/CY/CYpalp.html"
license=(GPL3)
depends=(glibc)
source=("http://hep.itp.tuwien.ac.at/~kreuzer/CY/$pkgname/$pkgname-$pkgver.tar.gz")
sha256sums=('723e89e78b2d3d94a720dd770c11b932b3e6b56f8a49e0bf3621c776f7a02ce0')

build() {
  cd $pkgname-$pkgver
  mkdir bin
  mv Global.h Global.h-template
  for dim in 4 5 6 11; do
    sed "s/^#define[^a-zA-Z]*POLY_Dmax.*/#define POLY_Dmax $dim/" Global.h-template > Global.h
    make
    for file in poly class cws nef mori; do
      mv ${file}.x bin/${file}-${dim}d.x
    done
  done
}

package() {
  cd $pkgname-$pkgver
  pushd bin
    for exe in *.x; do
	install -Dm755 $exe -t "$pkgdir"/usr/bin
    done
  popd
  for file in poly class cws nef mori; do
    ln -sf ${file}-6d.x "$pkgdir"/usr/bin/${file}.x
  done
}
